<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="../../js/echarts.min.js" charset="utf-8"></script>
</head>
<style>
    .div-1 {
        width: 100%;
        height: 670px;
    }

    .div-1-1 {
        width: 50%;
        height: 100%;
        float: left;
    }

    .div-1-2 {
        width: 50%;
        height: 100%;
        float: left;
    }
</style>

<body>
    <div class="div-1">
        <div class="div-1-1" id="pie">

        </div>
        <div class="div-1-2">

        </div>
    </div>
    <script>
        var chartDom = document.getElementById('pie');
        var myChart = echarts.init(chartDom);
        var option;
        $.ajax({
            url: "http://localhost:8080/admin/travel/way/queryWayTravelWayEchartPie",
            type: "post",
            data: {},
            success: function (result) {
                var arr = result.data.pie;
                // option = {
                //     legend: {
                //         top: 'bottom'
                //     },
                //     toolbox: {
                //         show: true,
                //         feature: {
                //         mark: { show: true },
                //         dataView: { show: true, readOnly: false },
                //         restore: { show: true },
                //         saveAsImage: { show: true }
                //         }
                //     },
                //     series: [
                //         {
                //         name: 'Nightingale Chart',
                //         type: 'pie',
                //         radius: [50, 250],
                //         center: ['50%', '50%'],
                //         roseType: 'area',
                //         itemStyle: {
                //             borderRadius: 8
                //         },
                //         data: arr
                //         }
                //     ]
                //     };

                //     myChart.setOption(option);
                option = {
                    tooltip: {
                        trigger: 'item'
                    },
                    legend: {
                        top: '5%',
                        left: 'center'
                    },
                    series: [
                        {
                            name: 'Access From',
                            type: 'pie',
                            radius: ['40%', '70%'],
                            avoidLabelOverlap: false,
                            itemStyle: {
                                borderRadius: 10,
                                borderColor: '#fff',
                                borderWidth: 2
                            },
                            label: {
                                show: false,
                                position: 'center'
                            },
                            emphasis: {
                                label: {
                                    show: true,
                                    fontSize: '40',
                                    fontWeight: 'bold'
                                }
                            },
                            labelLine: {
                                show: false
                            },
                            data: arr
                            // [
                            //     { value: 1048, name: 'Search Engine' },
                            //     { value: 735, name: 'Direct' },
                            //     { value: 580, name: 'Email' },
                            //     { value: 484, name: 'Union Ads' },
                            //     { value: 300, name: 'Video Ads' }
                            // ]
                        }
                    ]
                };

                option && myChart.setOption(option);
            }
        })
    </script>
</body>

</html>